package EstimatorPackage;

/**
 *
 * @author Martin Haulrich
 */
public class LaPlaceSuffix extends EmpSuffix {

    EmpSuffix emp;

    double disc;

    public LaPlaceSuffix(EmpSuffix emp) {
        this.emp = emp;
        this.diffSuf = emp.diffSuf;
        this.totalSuf = emp.totalSuf;
        this.wordsCount = emp.wordsCount;
        disc = 1.0 / (double) wordsCount;

    }

    @Override
    public double getEstimate(String s) {
        double c;
        if (s.isEmpty()) {
//            return 0;
            c = wordsCount;
        } else {
            c = (double) emp.getCount(s);
        }
        //double lc = (double) (emp.getCount(s) + 1) / (totalSuf + diffSuf);
//        double lc =  (((double) emp.getCount(s)) + disc) / ((double) wordsCount + 1.0);

        double est = (c + disc) / ((double) wordsCount + 1.0);
//        System.err.println(lc);
        //   System.err.println("    lapcount: " + lc);
//        System.err.println("Lap-ret: " + Math.log10(est));
        return Math.log10(est);
    }
}
